﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CommonsLib.Utility;
using System.Data.SqlClient;
using MaxLeaf.Platform.Functions;
using System.Data.Common;
using MaxLeaf.Platform.Commons;
using MaxLeaf.Platform.DataContract;
using CommonsLib.DB;

namespace MaxLeaf.Platform.DALImplementation
{
    public class InvLocQryDAL : BaseDAL
    {
        protected override string GetCondForPage(DBAccess dbcon, object model, List<Cond> lstCond)
        {
            string strCond = base.GetCondForPage(dbcon, model, lstCond);

            foreach (Cond cond in lstCond)
            {
                if (cond.PropName.Equals("Func_CheckGoodsCategoryName"))
                {
                    if (!string.IsNullOrEmpty(strCond))
                    {
                        strCond += " and ";
                    }
                    strCond += string.Format(@"  exists (select g_c.cat_id from {0}goods_category g_c
                                            where g_c.cat_name like '{1}' 
                                            and {0}F_ExistInGoodsCategory(GoodsID,g_c.cat_id)=1) "
                        , GetBaseDatabase()
                        , BaseFunc.SpecialCharDeal(CvtFunc.ToString(cond.Value))
                        );
                    continue;
                }

            }
            return strCond;
        }
        public override string GetTableName(object model)
        {
            return ImInvLocDAL.InvLocQryTableName(model);
        }

         
    }
}
